'''
Created on 2020年3月7日

@author: yinfs
'''
from dao import dbaccess

class CheckSystem(object):
    '''
    classdocs
    '''


    def __init__(self):
        '''
        Constructor
        '''
    
    def check_system(self):
        '''
        检查系统的执行环境是否具备
        '''
        flag = True
        db = dbaccess.DBAccess()
        try:
            query_sql = "SELECT COUNT(*) FROM sqlite_master where type='table' and name='photo_class'"
            ob = []
            res = db.execute_query(query_sql,ob)
            result =res.fetchall()
            count = result[0][0]
            if count == 0:
                #count == 0 表示没有photo_class 表需要初始化创建。
                cr = self.create_tab_photo_class() 
                if cr:
                    flag = True
                else:
                    flag = False
                
#             result = []
#             for result in res:
#                  print('COUNT:', result[0])
#             print("查询结果：",res)
            
        except Exception as e:
            print("查询错误:",e)
        db.close() 
        
        return flag  
        
    
        
        
        
        
           